
/*
 * Copyright 2016 Yonyou Auto Information Technology（Shanghai） Co., Ltd. All Rights Reserved.
 *
 * This software is published under the terms of the YONYOU Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 *
 * @Project Name : marketing-wechat-open-api
 *
 * @File name : MaintainController.java
 *
 * @Author : Wang HuiCheng
 *
 * @Date : 2016年11月3日
 *
 ----------------------------------------------------------------------------------
 *     Date             Who              Version     Comments
 * 1.  2016年11月3日    Wang HuiCheng    1.0
 *
 *
 *
 *
 ----------------------------------------------------------------------------------
 */
	
package com.yonyou.gmcc.gateway.wechat.controller.maintenanceorder;

import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.marketing.common.dto.maintenanceorder.MaintenanceDto;
import org.marketing.common.util.CheckUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.yonyou.gmcc.gateway.wechat.common.ApiVersionConsts;
import com.yonyou.gmcc.gateway.wechat.controller.BaseController;
import com.yonyou.gmcc.gateway.wechat.service.interfaces.MaintenanceorderServiceInterface;

/**
 * 维系履历CONTROLLER
 * @author QianKun
 * @date 2017年3月7日
 */
@RestController
@RequestMapping(value = ApiVersionConsts.BASE_PATH+"/maintenanceorder" )
public class MaintenanceorderController extends BaseController{
    
    private Logger logger = Logger.getLogger(MaintenanceorderController.class);
    
    @Autowired
    private MaintenanceorderServiceInterface maintenanceorderServiceInterface;
    
    /**
    * 维修履历列表查询
    * @author QianKun
    * @date 2017年3月7日
    * @param vin
    * @return
    * @throws Exception
    */
    @RequestMapping(value = "/getMaintenance",method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public List<MaintenanceDto> getMaintenance(@RequestParam("vin") String vin) throws Exception{
        List<MaintenanceDto> dtoList = null;
        try{ 
            dtoList = maintenanceorderServiceInterface.getMaintenance(vin);
        if (CheckUtil.NullOrEmpty(dtoList)) {
            dtoList = new ArrayList<>();
            }
        }catch(Exception e){
            this.logger.error(e.getMessage(),e);
            throw e;
        }
        return dtoList;
    }
}
